﻿<Window
  x:Class="Panel3D_Demo.BoundWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Panel3D Demo"
  Width="800" Height="810"
  WindowStartupLocation="CenterScreen"
  >
  <Window.Resources>
    <ResourceDictionary Source="Panel3DConfigurations.xaml" />
  </Window.Resources>

  <DockPanel>

    <TextBlock DockPanel.Dock="Top" Text="Selected Index:" Margin="20,0,0,0" />
    <Slider
      x:Name="selectedIndexSlider"
      DockPanel.Dock="Top"
      Margin="20,5"
      Minimum="0"
      Value="{Binding ElementName=listBox, Path=SelectedIndex, Mode=TwoWay}"
      AutoToolTipPlacement="BottomRight"
      AutoToolTipPrecision="0"
      />

    <StackPanel DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0,0,0,4">
      <StackPanel.Resources>
        <Style TargetType="{x:Type Button}">
          <Setter Property="Width" Value="140" />
        </Style>
        <Style TargetType="{x:Type RepeatButton}">
          <Setter Property="Interval" Value="500" />
          <Setter Property="Width" Value="60" />
        </Style>
      </StackPanel.Resources>
      <StackPanel HorizontalAlignment="Center" Margin="0,12" Orientation="Horizontal">
        <RepeatButton Click="PageBackButtonClicked" Content="|&lt;&lt;&lt;" ToolTip="Move Back 3 Items (Hold to Repeat)" />
        <Rectangle Width="10" />
        <RepeatButton Click="MoveBackButtonClicked" Content="|&lt;" ToolTip="Move Back 1 Item (Hold to Repeat)" />
        <Rectangle Width="10" />
        <RepeatButton Click="MoveForwardButtonClicked" Content="&gt;|" ToolTip="Move Forward 1 Item (Hold to Repeat)" />
        <Rectangle Width="10" />
        <RepeatButton Click="PageForwardButtonClicked" Content="&gt;&gt;&gt;|" ToolTip="Move Forward 3 Items (Hold to Repeat)" />
      </StackPanel>
      <StackPanel HorizontalAlignment="Center" Margin="0,12" Orientation="Horizontal">
        <Button Click="AddItemButtonClicked" Content="Add Item to End of List" />
        <Rectangle Width="10" />
        <Button Click="Append100ItemsButtonClicked" Content="Append 100 Items" />
        <Rectangle Width="10" />
        <Button Click="InsertItemButtonClicked" Content="Insert Item at [1]" />
      </StackPanel>
      <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
        <Button Click="RemoveItemButtonClicked" Content="Remove Item at [0]" />
        <Rectangle Width="10" />
        <Button Click="ResetDataSourceButtonClicked" Content="Reset Data Source" />
      </StackPanel>
    </StackPanel>

    <StackPanel DockPanel.Dock="Bottom" Height="190" Width="140">
      <Border BorderBrush="Gray"  BorderThickness="1" CornerRadius="4" Padding="4" SnapsToDevicePixels="True">
        <DockPanel x:Name="itemLayoutDirectionEditor">
          <TextBlock DockPanel.Dock="Top" Text="Item Layout Direction" TextAlignment="Center" FontWeight="Bold" />
          <TextBox x:Name="itemLayoutDirectionValue" DockPanel.Dock="Bottom" IsReadOnly="True" />
          <DockPanel>
            <Slider
              x:Name="itemLayoutDirectionEditorX"
              DockPanel.Dock="Top"
              Orientation="Horizontal"
              Minimum="-10" Maximum="+10"
              Value="{Binding Path=X}"
              />
            <Slider
              x:Name="itemLayoutDirectionEditorY"
              DockPanel.Dock="Left"
              Height="100"
              HorizontalAlignment="Left"
              Minimum="-10" Maximum="+10"
              Orientation="Vertical"
              Value="{Binding Path=Y}"
              />
            <Slider
              x:Name="itemLayoutDirectionEditorZ"
              Height="140"
              IsDirectionReversed="True"
              Minimum="-20" Maximum="-1"
              Orientation="Vertical"
              Value="{Binding Path=Z}"
              >
              <Slider.LayoutTransform>
                <RotateTransform Angle="-45" CenterX="0.5" CenterY="0.5" />
              </Slider.LayoutTransform>
            </Slider>
          </DockPanel>
        </DockPanel>
      </Border>
    </StackPanel>

    <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Center" Orientation="Horizontal">
      <TextBlock VerticalAlignment="Center">Panel3D Config:</TextBlock>
      <ComboBox x:Name="panelConfigSelector" Width="100" Margin="6" />
    </StackPanel>

    <StackPanel DockPanel.Dock="Bottom" Margin="6">
      <CheckBox
        x:Name="chkMoveItemToFrontOnClick"
        Content="Move item to front on click"
        IsChecked="True"
        />
      <CheckBox
        x:Name="chkAllowTransparency"
        Content="Allow Transparency"
        IsChecked="False"
        />
      <CheckBox
        x:Name="chkAutoAdjustOpacity"
        Content="Auto Adjust Opacity"
        IsChecked="True"
        />
    </StackPanel>

    <!-- Here is the ListBox that uses Panel3D to host its items. -->
    <ListBox x:Name="listBox"
      Focusable="False"
      IsSynchronizedWithCurrentItem="True"
      ItemsPanel="{StaticResource Default}"
      ItemsSource="{Binding Path=.}"
      >
      <ListBox.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}">
          <Setter Property="HorizontalContentAlignment" Value="Stretch" />
          <Setter Property="Width" Value="200" />
          <Setter Property="Height" Value="200" />
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                <ContentPresenter ContentSource="Content" />
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </ListBox.ItemContainerStyle>

      <ListBox.ItemTemplate>
        <DataTemplate>
          <Button
            Background="#EE000000"
            Click="OnItemClick"
            Cursor="Hand"
            Focusable="False"
            Foreground="Red"
            >
            <TextBlock
              FontSize="30"
              FontWeight="Bold"
              Text="{Binding Path=.}"
              />
          </Button>
        </DataTemplate>
      </ListBox.ItemTemplate>
    </ListBox>

  </DockPanel>
</Window>